<template>
    <div class='dialog'>
        <div class='newAdd dialog-con update-platform-container'>
          <split-vertical title="编辑平台信息"></split-vertical>
          <div class="form">
            <el-form ref="ruleForm" label-width="110px" class="demo-ruleForm" label-position="right">
              <el-form-item label="平台性质" >
                <el-radio-group v-model="add.platformNature" @change="selectNature">
                  <el-radio label="A">银行</el-radio>
                  <el-radio label="B">电商</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="平台名称">
                <el-input v-model="add.platformName" style="width: 96%;"></el-input>
              </el-form-item>
              <el-form-item label="合作公司" >
                <el-select v-model="add.companyId" placeholder="请选择" size="medium"  filterable allow-create clearable style="width: 96%;">
                  <el-option
                    v-for="item in list"
                    :key="item.id"
                    :label="item.companyName"
                    :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item class="btn" >
                <el-button @click="confirm" type="primary"  size="medium">提交</el-button>
                <el-button @click="cancel"  size="medium" style="margin-right:20px">取消</el-button>
              </el-form-item>
            </el-form>
          </div>

        </div>
    </div>
</template>
<script>
import SplitVertical from "components/common/SplitVertical"

import {localStorage} from 'js/localStorage'
export default {
  inject: ["reload"],
  components:{
      SplitVertical
  },
  data() {
    return {
      userId:'',
      dis_phone:false,
      list:[]
    };
  },
  props: {
    add: {}
  },
  created(){
  this.userId=localStorage.get('userID')
    this.getAllCompany()
  },
  methods: {
    getAllCompany(){
      let success=data=>{
        if(data.statusCode == '1'){
          this.list= data.body
        }else{
          this.$message.error(data.msg)
        }
      }
      this.api.getCompanyListByNature({},success)
    },
    confirm() {
      let parmas=this.add
         parmas['userId']=this.userId
      let success = data => {
        if (data.statusCode === "1") {
          this.$message.success("保存成功");
          this.reload();
          this.$emit("closeDialog");
        } else {
          this.$message.error(data.statusMessage);
        }
      };
      this.api.platformUpdate(parmas, success);
    },
    cancel() {
      this.$emit("closeDialog");
    },
    selectNature() {

    },
  }
};
</script>
<style lang="scss" scoped>
.update-platform-container {
  width: 400px;
  height: 300px;

  .update-platform {
    margin-left: 5%;
    span{
      color:red;
      margin-right: 5px;
    }
    label {
      width: 110px;
      font-size:14px;
      display: inline-block;
      color:#606266;
    }
    .el-input{
      height: 40px;
      width:300px;
      margin: 20px 0 10px 0;
      font-size:14px;
      color:#606266;
    }
    p{
      margin-left:22%;
      color:red;
      font-size:12px;
    }
  }
  .btn {
     text-align: right;
     padding-top: 20px;
  }
}
</style>

